package fule.com.playandroidkotlin.ui.presenter

import fule.com.playandroidkotlin.base.BaseModel
import fule.com.playandroidkotlin.base.BaseObserver
import fule.com.playandroidkotlin.base.BasePresenter
import fule.com.playandroidkotlin.ui.model.SearchModel
import fule.com.playandroidkotlin.ui.view.SearchResultView

/**
 *@author: njb
 *@date:   2020/2/6 0006 18:11
 *@desc:
 */
class SearchResultPresenter(baseView: SearchResultView) : BasePresenter<SearchResultView>(baseView) {

    /**
     * 搜索
     */
    fun query(page: Int, k: String) {
        addDisposable(apiServer.query(page, k), object : BaseObserver<BaseModel<SearchModel>>(baseView) {
            override fun onSuccess(o: BaseModel<SearchModel>) {
                baseView.onLoadSearcher(o.data!!)
            }
            override fun onError(msg: String?) {
                    baseView.showError(msg!!)
            }
        })
    }

}